#include <iostream>
#include <cstdio>

using namespace std;

struct BTree{
	BTree * child;
	BTree * brother;
	int data;
	BTree(int d){
		data = d;
		child = brother = nullptr;
	}
	
	void add(BTree * t)
	{
		if(nullptr == child)
		{
			child = t;
		}
		else
		{
			child->Add_brother(t);
		}
	}
	
	void Add_brother(BTree * t)
	{
		if(nullptr == brother)
		{
			brother = t;
		}
		else
		{
			brother->Add_brother(t);
		}
	}
	
	void pre_order(BTree * t)
	{
		cout<<t->data<<endl;
		if(t->child != nullptr){
			//TODO
			pre_order(t->child);
		}
		if(t->brother != nullptr)
		pre_order(t->brother);
	}
	
	
	void in_order(BTree * t)
	{
		if(t->child != nullptr)
		in_order(t->child);
		cout<<t->data<<"	";
		if(t->brother != nullptr)
		in_order(t->brother);
	}
	
	void pre_orderEX()
	{
		cout<<data<<"	";
		if(child) child->pre_orderEX();
		if(brother)  brother->pre_orderEX();
	}
};

int main()
{
	BTree * t = new BTree(1);
	t->add(new BTree(2));
	t->add(new BTree(3));
	t->add(new BTree(4));
	t->child->brother->add(new BTree(5));
	t->child->brother->add(new BTree(6));

//t->pre_order(t)	;
t->pre_orderEX();
cout<<endl;
t->in_order(t);

	return 0;
}
